package com.authine.cloudpivot.app.openapi.config;

import com.alibaba.cola.boot.SpringBootstrap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

/**
 * Configuration for COLA framework
 * @author lifuchun
 */
@Configuration
@Slf4j
public class ColaConfig {

    @Bean(initMethod = "init")
    public SpringBootstrap bootstrap() {
        return new SpringBootstrap();
    }

    @Bean
    public RestTemplate restTemplate() {

        log.info("初始化restTemplate");

        return new RestTemplateBuilder()
                .setConnectTimeout(Duration.ofSeconds(30))
                .setReadTimeout(Duration.ofSeconds(30))
                .build();
    }
}